﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RaisingStudio.Data.Providers;
using SqlCe4Mvc3Application1.Models;
using System.IO;

namespace SqlCe4Mvc3Application1.Areas.TestArea.Controllers
{
    public class HelloController : Controller
    {
        //
        // GET: /TestArea/Hello/

        public DataContext CreateIndividualDataContext(string workingPath)
        {
            AppDomain.CurrentDomain.SetData("TestArea_DataDirectory", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Areas\TestArea\App_Data"));
            string dataPath = AppDomain.CurrentDomain.GetData("DataDirectory") as string;
            string testArea_DataDirectory = AppDomain.CurrentDomain.GetData("TestArea_DataDirectory") as string;
            return DataContext.CreateInstance(workingPath, "TestArea");
        }

        public ActionResult Index()
        {
            DataContext dataContext = CreateIndividualDataContext(@"Areas\TestArea");
            var records = dataContext.Query<Common_BodyPartRecord>();
            return View(records);
        }

    }
}
